/*
* @Author: majingyu
* @Date:   2017-05-28 22:10:41
* @Last Modified by:   majingyu
* @Last Modified time: 2017-06-08 10:34:10
*/

import React, { Component }from 'react';
import { connect } from 'react-redux';
import OrderList from 'components/myOrder.jsx';
import { getCommontList } from 'action/commont.js';
import 'css/commontList.less';
 
class CommontList extends Component{
    constructor(props) {
        super(props);
         this.getList();
    }  
    getList(){
        let data = {
            pageNo: this.props.commont.commontList.pageNo,
            pageSize: 10,
            id: this.props.commont.commontId
        }
        this.props.getCommontList(data);
    }
    render(){
        let commontList = this.props.commont ? this.props.commont.commontList.list.map((item) => {
            return (
                <div className="commontText" key={item.id}>
                    <p className="text">{item.text}</p>
                    <p className="user-mess">
                        <span className="user">{item.user}</span>
                        <span className="time">2017-03-03</span>
                    </p>
                </div>
            );
        }): <div className="list-mess">暂时无数据</div>
        console.log(commontList);
        return(
            <div className="content">
                {commontList}
            </div>
        );
    }
}
const commontListData = (state) => {
    return {
        commont: state.commont
    }
}
let dispatchHandle = (dispatch, getState) => {
    return {
        getCommontList(data){
            dispatch(getCommontList(data)) 
        }
        
    }
    
}
let visibileCommontList= connect(commontListData,dispatchHandle)(CommontList);


export default visibileCommontList;